<%@page import="com.zretc.entity.Fdtype"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title>菜系管理</title>

<!-- 分页有关 1 引入layui.css文件 -->
<link rel="stylesheet" href="layui/css/layui.css" media="all">

<!--1. Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<!--2. Custom styles for this template -->
<link href="css/dashboard.css" rel="stylesheet">


</head>
<body>

	<jsp:include page="nav.html"></jsp:include>

	<div class="container-fluid">
		<div class="row">
			<div class="col-sm-3 col-md-2 sidebar">
				<ul class="nav nav-sidebar">
					<li class="active"><a href="FdTypeServlet?op=queryByPage">菜系管理<span
							class="sr-only">(current)</span></a></li>
					<li><a href="FoodServlet?op=queryByPage">菜品管理<span
							class="sr-only">(current)</span></a></li>
					<li><a href="addtype.jsp">订单管理</a></li>
					<li><a href="NewsServlet">用户管理<span class="sr-only">(current)</span></a></li>
					<li><a href="addnews.jsp">管理员管理</a></li>
				</ul>

			</div>
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
				<h2 class="sub-header">
					菜系管理

					<form class="navbar-form navbar-right" action="FdTypeServlet"
						method="post">
						<input type="text" class="form-control" name="keywords"
							id="keywords" value="${keywords}" placeholder="查询的关键字或添加的名称">
						<input type="hidden" name="op" value="queryByPage"> <input
							type="submit" class="btn btn-primary" value="查询"> <a
							href="addfdtype.jsp"><input name="添加" type="button"
							class="btn btn-primary" value="添加菜系"></a>
					</form>
				</h2>





				<div class="table-responsive" style="height: 430px">
					<table class="table table-striped">
						<thead>
							<tr>
								<th>菜系编号</th>
								<th>菜系名称</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<!-- 如果属性范围内的pd为null，我们就跳转到NewsTypeServlet去获取数据，然后再转发回来 -->
							<c:if test="${fd==null}">
								<!-- c:redirect 跳转到 NewsTypeServlet -->
								<c:redirect url="FdTypeServlet?op=queryByPage"></c:redirect>
							</c:if>
							<!-- 如果 范围内的list不为空，遍历数据并展示结果 -->
							<c:if test="${fd!=null}">
								<c:forEach items="${fd.data}" var="fdtype">
									<tr>
										<td>${fdtype.fdtypeid}</td>
										<td>${fdtype.fdtypename}</td>
										<td><a href="#">删除</a></td>

									</tr>
								</c:forEach>
							</c:if>
						</tbody>
					</table>
				</div>
				<!-- 显示 分页导航区域 -->
				<div id="pagediv" style="text-align: center"></div>

			</div>
		</div>
	</div>

	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!--3 - js/jquery-2.0.3.js -->
	<script src="js/jquery-2.0.3.js"></script>
	<!--4 - ootstrap.min.js -->
	<script src="dist/js/bootstrap.min.js"></script>

	<!--分页操作 2- 引入layui.js文件 -->
	<script src="layui/layui.js" charset="utf-8"></script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
  layui.use(['laypage', 'layer'], function(){

	

  var laypage = layui.laypage
  ,layer = layui.layer;
  
//完整功能
 laypage.render({
    elem: 'pagediv' // 分页的导航在哪里显示，pagediv是层id
    ,theme: '#428bca'  //颜色
    ,count: ${fd.totalCount} //总记录数
    ,curr: ${fd.page}  //当前页
    ,limit: ${fd.pageSize}//当前页显示的记录数
    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
    ,jump: function(obj, first){ //跳转页面时候的动作
	    //obj包含了当前分页的所有参数，比如：
	    // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
	   // console.log(obj.limit); //得到每页显示的条数
	    
	    //首次不执行
	    if(!first){
	      //do something
	       location.href="FdTypeServlet?op=queryByPage&page="+obj.curr+"&pageSize="+obj.limit+"&keywords="+$("#keywords").val();
	    }
	  }
  });
  
  
  
  
  
  
  
  
});
  
</script>


</body>
</html>